import Vue from 'vue'
import VueRouter from 'vue-router'
// 全局导入要用到的import
// import Home from '@/views/Home.vue'

// 全局使用VueRouter
Vue.use(VueRouter)

// 配置路由
const routes = [
  {
    path: '/',
    name: 'main',
    redirect: '/home', //添加重定向
    // 全局导入路由
    // component: Home
    // 按需导入路由
    component: () => import('@/views/Main.vue'),
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/Home.vue')
      },
      {
        path: '/user',
        name: 'user',
        component: () => import('@/views/User.vue')
      },
      {
        path: '/mall',
        name: 'mall',
        component: () => import('@/views/mall.vue')
      },
      {
        path: '/page1',
        name: 'page1',
        component: () => import('@/views/order/pageOne.vue')
      },
      {
        path: '/page2',
        name: 'page2',
        component: () => import('@/views/order/pageTwo.vue')
      }
    ]
  }
]

// 创建并配置VueRouter实例
const router = new VueRouter({ mode: 'history', routes })

export default router
